//
//  MeatMineViewController.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/30.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatMineViewController.h"
#import "EditShopViewController.h"

#import "MeatMineTableViewCell.h"

#import "MeatMineHeader.h"
#import "MeatMineFooter.h"
#import "MeatMineBlankView.h"



@interface MeatMineViewController ()

@property (nonatomic, strong) MeatMineHeader *header;

@property (nonatomic, strong) MeatMineFooter *footer;

@property (nonatomic, strong) MeatMineBlankView *blankView;


@end

@implementation MeatMineViewController

#pragma mark - lifecycle methods

- (void)setupUI{
    
    [self.view  addSubview:self.blankView];
    self.baseNavView.hidden = YES;
    self.tableView.hidden = YES;
}

- (void)setupLayout{
    
    {
        CGFloat h = KScreenHeight - (TJ_MeatShop_Header + _footer.height + 42);
        _blankView.mj_y = (h - _blankView.height)/2.0 - 20;
    }

}

#pragma mark - networking methods
#pragma mark - response methods
#pragma mark - public methods

#pragma mark - tableview delegate/dataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 123;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    MeatMineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MeatMineTableViewCell"];
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}

#pragma mark - setter and getter


#pragma mark - override methods

- (void)registerTableViewCell{
    
    
    CGFloat kTableViewHeight = KScreenHeight - 192 - TJ_TabBarHeight;
    self.tableView.height = kTableViewHeight;
    self.tableView.separatorColor = mIconLineColor;
    self.tableView.tableHeaderView = self.header;
    self.tableView.tableFooterView = self.footer;

    [self.tableView registerClass:[MeatMineTableViewCell class] forCellReuseIdentifier:@"MeatMineTableViewCell"];

}

- (MeatMineHeader *)header{
    
    if (!_header) {
        _header = [[MeatMineHeader alloc] init];
    }
    return _header;
}

- (MeatMineFooter *)footer{
    
    if (!_footer) {
        _footer = [[MeatMineFooter alloc] init];
    }
    return _footer;
}

- (MeatMineBlankView *)blankView{
    
    if (!_blankView) {
        _blankView = [[MeatMineBlankView alloc] init];
        _blankView.type = MeatMineBlankViewType_OpenShop;
        //_blankView.hidden = YES;
        
        @weakify(self);
        _blankView.dealJumpBlock = ^(NSInteger params) {
            @strongify(self);
            
            if (params == 1) {
                [self showHudWithMsg:@"去领养"];
                
            }else{
                
                EditShopViewController *vc = [[EditShopViewController alloc] init];
                [self.navigationController pushViewController:vc animated:YES];
            }
        };
        
    }
    return _blankView;
}




@end
